﻿using System.Collections.Generic;
using NH.OpenClosedPrinciple;

namespace NH.OpenClosedPrinciple.FirstAttempt{


	public class ProductFilter
	{
		public IEnumerable<Product> ByColor(IList<Product> products, ProductColour productColor) {
			foreach (var product in products) {
				if (product.Colour == productColor)
					yield return product;
			}
		}

		public IEnumerable<Product> ByColorAndSize(IList<Product> products,
													ProductColour productColor,
													ProductSize productSize) {
			foreach (var product in products) {
				if ((product.Colour == productColor) &&
					(product.Size == productSize))
					yield return product;
			}
		}

		public IEnumerable<Product> BySize(IList<Product> products,
											ProductSize productSize) {
			foreach (var product in products) {
				if ((product.Size == productSize))
					yield return product;
			}
		}
	}
}
